<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="t" tagdir="/WEB-INF/tags" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<t:emptyTemplate>

<script>			
		$(function() {			
			
			$('#barriochoferList').jqGrid({
				url:'chofer?action=getBarriosExcluidos&entity=chofer&filterValue='+$('#id').val(),
				datatype: 'json',
				colNames:['Id', 'Barrio'],
				colModel :[
					{name:'id', index:'id', width:55, hidden:true},
					{name:'barrio', index:'barrio', width:100 , searchoptions: { sopt: ['eq', 'bw', 'ew'] }}
				],
				pager: '#barriochoferPager',
				height: 150,
				width: 500,
				rowNum:100,
				rowList:[100,150,200],
				sortname: 'id',
				sortorder: 'asc',
				viewrecords: true,
				gridview: true,
				caption: 'Barrios excluidos para el chofer',
				ondblClickRow: function(id){
					if(id) {
						;
	  				}
				}
			});
			
			makeDropDownSelector('barrio', 'barrio', null, true);

		});
		
		function excluirBarrio() {
			
			if($('#barrio').val()) {
				jQuery.ajax({											
					url: 'chofer?action=excluirBarrio&idchofer='+$('#id').val()+
												  	'&idbarrio='+$('#barrio').val(),
					dataType: 'json',
					success: function(data) {
									jQuery('#barriochoferList').trigger("reloadGrid");
							}										
				});
			}
		}
	</script>
	
	<form name="formMain" id="formMain" method="post" action="chofer?action=guardar">
	
		<div class="container_14">
	
			<div class="grid_7 alpha box" style="height: auto;">
				<div class="grid_2 alpha">
					Barrios
				</div>
				<div class="grid_4 omega">
					<select name="barrio" id="barrio"></select>
					<input type="button" name="save" id="save" value="Excluir" onclick="excluirBarrio();">
				</div>
				
			</div>
			
		</div>
		
		<input type="hidden" name="id" id="id" value="${entity.id}">
		<input type="hidden" name="entity" id="entity" value="chofer">

	</form>	
	
	<div class="grid_10 alpha omega" style="margin-top: 20px;">
		<table id="barriochoferList"><tr><td/></tr></table>
		<div id="barriochoferPager"></div>
	</div>

</t:emptyTemplate>